{template 'web/_header'}
{template 'tabs'}

{if $operation == 'post'}
<div class="main">
    <form action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
        <input type="hidden" name="id" value="{$item['id']}" />
        <div class='panel panel-default'>
            <div class='panel-heading'>
                角色设置
            </div>
            <div class='panel-body'>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style='color:red'>*</span> 角色</label>
                    <div class="col-sm-9 col-xs-12">
                        {ife 'perm.role' $item}
                        <input type="text" name="rolename" class="form-control" value="{$item['rolename']}" />
                        {else}
                        <div class='form-control-static'>{$item['rolename']}</div>
                        {/if}
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">状态</label>
                    <div class="col-sm-9 col-xs-12">
                         {ife 'perm.role' $item}
                        <label class='radio-inline'>
                            <input type='radio' name='status' value=1' {if $item['status']==1}checked{/if} /> 启用
                        </label>
                        <label class='radio-inline'> 
                            <input type='radio' name='status' value=0' {if $item['status']==0}checked{/if} /> 禁用
                        </label>
                        <span class="help-block">如果禁用，则当前角色的操作员全部会禁止使用</span>
                        {else}
                        <div class='form-control-static'>{if $item['status']==1}启用{else}禁用{/if}</div>
                        {/if}
                    </div>
                </div>
                {template 'perms'}
                         {ife 'perm.role' $item}
                 {else}
                 <script language='javascript'>
                     $(function(){
                         $(':checkbox').attr('disabled',true);
                     })
                     </script>
                     {/if}
                    <div class="form-group"></div>
            <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
                    <div class="col-sm-9 col-xs-12">
                           {ife 'perm.role' $item}
                            <input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1"  />
                            <input type="hidden" name="token" value="{$_W['token']}" />
                        {/if}
                       <input type="button" name="back" onclick='history.back()' {ifp 'perm.role.add|perm.role.edit'}style='margin-left:10px;'{/if} value="返回列表" class="btn btn-default" />
                    </div>
            </div>
            </div>
        </div>
    
    </form>
</div>
<script language='javascript'>
 
    $('form').submit(function(){
        if($(':input[name=rolename]').isEmpty()){
            Tip.focus($(':input[name=rolename]'),'请输入角色名称!');
            return false;
        }
        return true;
    })
    </script>
{elseif $operation == 'display'}
        <form action="" method="get" class='form form-horizontal'>
                   <div class="panel panel-info">
        <div class="panel-heading">筛选</div>
        <div class="panel-body">
            <form action="./index.php" method="get" class="form-horizontal" role="form">
                <input type="hidden" name="c" value="site" />
                <input type="hidden" name="a" value="entry" />
                <input type="hidden" name="m" value="sz_yi" />
                <input type="hidden" name="do" value="plugin" />
                <input type="hidden" name="p"  value="perm" />
                <input type="hidden" name="method"  value="role" />
                <input type="hidden" name="op" value="display" />
                <div class="form-group">
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">关键字</label>
                    <div class="col-xs-12 col-sm-8 col-lg-9">
                        <input class="form-control" name="keyword" id="" type="text" value="{$_GPC['keyword']}" placeholder="可搜索角色名称">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">状态</label>
                    <div class="col-xs-12 col-sm-8 col-lg-9">
                           <select name="status" class='form-control'>
                           <option value="" {if $_GPC['status']==''} selected{/if}></option>
                            <option value="1" {if $_GPC['status'] == '1'} selected{/if}>启用</option>
                            <option value="0" {if $_GPC['status'] == '0'} selected{/if}>禁用</option>
                        </select>  </div>
                     <div class="col-xs-12 col-sm-2 col-lg-2">
                        <button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
                    </div>
                </div>
              
            </form>
        </div>
    </div>
                   
     <div class='panel panel-default'>
            <div class='panel-heading'>
                角色设置
            </div>
         <div class='panel-body'>

            <table class="table">
                <thead>
                    <tr>
                        <th>角色名称</th>
                        <th>操作员数量</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    {loop $list $row}
                    <tr>
                        <td>{$row['rolename']}</td>
                        <td>{$row['usercount']}</td>                            
                                 <td>
                                    {if $row['status']==1}
                                    <span class='label label-success'>启用</span>
                                    {else}
                                    <span class='label label-danger'>禁用</span>
                                    {/if}
                                </td>
                        <td>
                          {ifp 'perm.role.edit|perm.role.view'}<a class='btn btn-default' href="{php echo $this->createPluginWebUrl('perm/role', array('op' => 'post', 'id' => $row['id']))}"><i class="fa fa-edit"></i></a>{/if}
                          {ifp 'perm.role.delete'}<a class='btn btn-default'  href="{php echo $this->createPluginWebUrl('perm/role', array('op' => 'delete', 'id' => $row['id']))}" onclick="return confirm('确认删除此门店吗？');return false;"><i class="fa fa-remove"></i></a>{/if}
                        </td>

                    </tr>
                    {/loop}
               
                </tbody>
            </table>
   {$pager}
         </div>
              {if 'perm.role.add'}
                 <div class='panel-footer'>
                              <a class='btn btn-default' href="{php echo $this->createPluginWebUrl('perm/role', array('op' => 'post'))}"><i class="fa fa-plus"></i> 添加新角色</a>
                 </div>
                    {/if}
                  
         
     </div>
       </form>
{/if}
{template 'web/_footer'}
